home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / expanded.lha / expanded / hdr / Object.h < prev    next >
C/C++ Source or Header  |  1992-03-19  |  4KB  |  152 lines

  1. //
  2. // Linear-Affine-Projective Geometry Package
  3. //
  4. // Object.h
  5. //
  6. // $Header$
  7. //
  8. // William J.R. Longabaugh 
  9. // University of Washington
  10. //
  11. // Implementation of the linear-affine-projective geometry
  12. // package described in William J.R. Longabaugh, "An Expanded
  13. // System for Coordinate-Free Geometric Programming", Master's 
  14. // thesis, University of Washington, 1992.
  15. //
  16. // Copyright (c) 1992, William J.R. Longabaugh
  17. //   Copying, use and development for non-commercial purposes permitted.
  18. //   All rights for commercial use reserved.
  19. //   This software is unsupported and without warranty; it is
  20. //   provided "as is".
  21. //
  22. // ***********************************************************************
  23.  
  24. #ifndef Object_h
  25. #define Object_h
  26.  
  27. #include <stream.h>
  28. #include "Lap1.h"
  29. #include "Typeout.h"
  30.  
  31. // Define nil pointer:
  32.  
  33. #define nil ((void *)0)
  34.  
  35. // Indent blocks in error outputs by 3 columns:
  36.  
  37. const int ERR_IND = 3;
  38.  
  39. // A line of asterisks:
  40.  
  41. extern const char *ast;
  42.  
  43. // ***********************************************************************
  44. //
  45. // Every class (except the error handler) in the package is a subclass
  46. // of this class.  Objects know how to print themselves out for
  47. // error messages.  The print function is virtual, and is implemented
  48. // by each different object.
  49. //
  50.   
  51. class Object
  52. {
  53.         friend ostream& operator<<(ostream &c, Object &o);
  54.  
  55.   public:
  56.  
  57.         virtual void debug_out(ostream &c, int indent) {};
  58. };
  59.  
  60. // ***********************************************************************
  61. //
  62. // A special class that is used to print out numeric values in
  63. // error messages.
  64. //
  65.   
  66. class ErrVal: public Object
  67. {
  68.   private:
  69.  
  70.         char  *text;
  71.     Boolean isint;
  72.         Scalar value;
  73.  
  74.   public:
  75.  
  76. // Constructors / Destructors:
  77.  
  78.         ErrVal(char *message, Scalar val);
  79.         ErrVal(char *message, int val);
  80.         ~ErrVal(void);
  81.  
  82. // To do debug printing:
  83.  
  84.         void debug_out(ostream &c, int indent);
  85. };
  86.  
  87. // ***********************************************************************
  88. //
  89. // A special class that is used to enumeration types in error messages.
  90. //
  91.   
  92. class ErrType: public Object
  93. {
  94.   private:
  95.  
  96.         char   *text;
  97.     int     value;
  98.         EnumSet set;
  99.  
  100.   public:
  101.  
  102. // Constructors / Destructors:
  103.  
  104.         ErrType(char *message, int val, EnumSet s);
  105.         ~ErrType(void);
  106.  
  107. // To do debug printing:
  108.  
  109.         void debug_out(ostream &c, int indent);
  110. };
  111.  
  112. // ***********************************************************************
  113. //
  114. // This class of objects handles error reporting.
  115. //
  116.  
  117. class ErrorHandler
  118. {
  119.   public:
  120.  
  121. // Creation:
  122.  
  123.         ErrorHandler(void);
  124.  
  125. // A whole bunch of error handling functions to handle different numbers
  126. // of Objects:
  127.  
  128.         void ErrorExit(char *errloc, char *descript);
  129.         void ErrorExit(char *errloc, char *descript, Object &o1);
  130.         void ErrorExit(char *errloc, char *descript, Object &o1,
  131.                        Object &o2);
  132.         void ErrorExit(char *errloc, char *descript, Object &o1,
  133.                        Object &o2, Object &o3);
  134.         void ErrorExit(char *errloc, char *descript, Object &o1,
  135.                        Object &o2, Object &o3, Object &o4);
  136.         void ErrorExit(char *errloc, char *descript, Object &o1,
  137.                        Object &o2, Object &o3, Object &o4, Object &o5);
  138. };
  139.  
  140. // ***********************************************************************
  141. // ***********************************************************************
  142. //
  143. // Announce the existence of the global error handler:
  144. //
  145.  
  146. extern ErrorHandler errh;
  147.  
  148. // ***********************************************************************
  149. // ***********************************************************************
  150.  
  151. #endif
  152.